package com.cily.utils.t_webrtc;

import android.os.Bundle;

import com.cily.utils.app.Init;
import com.cily.utils.app.ac.BaseActivity;
import com.cily.utils.app.utils.SpUtils;
import com.cily.utils.base.StrUtils;
import com.cily.utils.base.log.LogType;
import com.cily.utils.t_webrtc.pad.PadAc2;
import com.cily.utils.t_webrtc.pad.PhoneWaitAc;
import com.cily.utils.t_webrtc.utils.WsUtils;

import org.webrtc.Logging;

public class SplashActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_splash);
        Init.init(BuildConfig.DEBUG);
        Init.initLog(LogType.INFO);

        Logging.enableLogToDebugOutput(Logging.Severity.LS_NONE);

        if (StrUtils.isEmpty(SpUtils.getStr(this, Conf.USER_ROOM, null))) {
            toAc(LoginAc.class, null);
        } else {
            if(!WsUtils.isNetAvailable(this)){
                showToast("网络不可用，请检查网络");
                toAc(LoginAc.class, null);
                finish();
                return;
            }

            WsUtils.startWs(this, SpUtils.getStr(this, Conf.USER_ROOM, null));

            if (BuildConfig.TYPE_APP == 0) {
                toAc(PadAc2.class, null);
            } else if (BuildConfig.TYPE_APP == 1) {
                toAc(PhoneWaitAc.class, null);
            }
        }
        finish();
    }
}